package com.ybkj.daijia.api.weixin.handler.impl;

import com.ybkj.daijia.api.weixin.WxMsgType;
import com.ybkj.daijia.api.weixin.entity.WxBaseMsgEntity;
import com.ybkj.daijia.api.weixin.entity.WxBaseRespEntity;
import com.ybkj.daijia.api.weixin.entity.WxMsgLocEntity;
import com.ybkj.daijia.api.weixin.handler.WxHandler;
import java.util.Map;

public abstract class AbstractWxLocationHandler implements WxHandler {

    @Override
    public Integer priority() {

        return 3;
    }


    @Override
    public boolean canHandle(WxBaseMsgEntity msg) {

        if (WxMsgType.valueOf(msg.getMsgType()).compareTo(WxMsgType.location) == 0) {

            return true;
        }

        return false;
    }


    @Override
    public WxBaseRespEntity doHandle(WxBaseMsgEntity msg, Map<String, Object> context,
        WxBaseRespEntity resp) {

        if (WxMsgType.valueOf(msg.getMsgType()).compareTo(WxMsgType.location) == 0) {

            return handleLocation((WxMsgLocEntity) msg, context, resp);
        }

        return resp;
    }

    public abstract WxBaseRespEntity handleLocation(WxMsgLocEntity msg, Map<String, Object> context,
        WxBaseRespEntity resp);
}
